@extends("admin.base.base")
@section("title")
<title>新增图片</title>
<link href="{{asset('lib/webuploader/0.1.5/webuploader.css')}}" rel="stylesheet" type="text/css" />
<link href="{{asset('css/admin/css/picture.css')}}" rel="stylesheet" type="text/css" />
@endsection
@section("content")
<div class="page-container">
	<form class="form form-horizontal" id="form-article-add" enctype="multipart/form-data">
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>广告位名称：</label>
            <div class="formControls col-xs-3 col-sm-3">
                <input type="text" class="input-text" value="" placeholder="" id="" name="title">
            </div>
        </div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2">广告位宽度：</label>
			<div class="formControls col-xs-3 col-sm-3">
				<input type="text" class="input-text" value="" placeholder="建议宽度为1200px，默认为1200px" id="" name="width">
			</div>
            像素
		</div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2">广告位高度：</label>
            <div class="formControls col-xs-3 col-sm-3">
                <input type="text" class="input-text" value="" placeholder="" id="" name="height">
            </div>
            像素
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2">广告位描述：</label>
            <div class="formControls col-xs-3 col-sm-3">
                <input type="text" class="input-text" value="" placeholder="" id="" name="description">
            </div>
        </div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2">广告位模板：</label>
			<div class="formControls col-xs-4 col-sm-4">
				<textarea name="code" cols="" rows="" class="textarea"  placeholder="" datatype="*10-100" dragonfly="true" nullmsg="备注不能为空！">

                </textarea>
			</div>
            <div class="formControls col-xs-4 col-sm-4">
				<span style="color: #cccccc">请复制代码到需要放置的区域</span>
            </div>
		</div>
        {{csrf_field()}}
		<div class="row cl">
			<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-2">
				<button onClick="article_save();" class="btn btn-secondary radius" type="button"><i class="Hui-iconfont">&#xe632;</i> 保存提交</button>
				<button onClick="layer_close();" class="btn btn-default radius" type="button">&nbsp;&nbsp;取消&nbsp;&nbsp;</button>
			</div>
		</div>
	</form>
</div>
@endsection
@section("js")
<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="{{asset('lib/jquery.validation/1.14.0/jquery.validate.js')}}"></script>
<script type="text/javascript" src="{{asset('lib/jquery.validation/1.14.0/validate-methods.js')}}"></script>
<script type="text/javascript" src="{{asset('lib/jquery.validation/1.14.0/messages_zh.js')}}"></script>
<script type="text/javascript">
//ajax表单提交并实现文件上传
function article_save(){
    var formData = $("#form-article-add").serializeArray();
    console.log(formData);
	$.ajax({
       type:"post",
        data:formData,
       url:"{{url('admin/adv')}}",
       dataType:"json",
        success:function (resp) {
            if (resp.code == 0){
                layer.msg(resp.msg);
                setTimeout(function () {
                    window.location.href = '{{url('admin/adv')}}';
                },1000);
            }else {
                layer.msg(resp.msg);
            }
        }
    });

}
</script>
@endsection